{// 加载头部公共文件 }
<include file="Public:header" />
<div class="main">
	<div class="content">
		<table id="checkList" class="list" cellpadding=0 cellspacing=0>
			<tr>
				<td height="3" colspan="2" class="toptd"></td>
			</tr>
			<tr class="row">
				<th colspan="2" class="space">发送邮件</th>
			</tr>
			<tr class="row">
				<td width="15%">玩家名称:</td>
				<td>
					<input type="text" id="uname" name="uname"/>
					<button onclick="checkUser()">查询</button>
					用户ID为:<span id="userinfo"></span>
				</td>
			</tr>
			<tr class="row">
				<td width="15%">标题:</td>
				<td><input type="text" id="title" name="title" /></td>
			</tr>
			<tr class="row">
				<td width="15%">内容:</td>
				<td><textarea id="content" name="content"  cols=40 rows=10></textarea></td>
			</tr>
			<tr class="row">
				<td width="15%">物品ID:
				</td>
				<td>
					<input type="text" id="goods_id" name="goods_id" onchange="goodsChang();" value=0 />如果不发物品，只发钱就留空
					<img src="" id="goodsImg"></img>
					<select id="commenItem">
						<option>选择常用物品</option>
						<option value="28119">新手卡礼包</option>
						<option value="16003">独角兽</option>
						<option value="24302">钻石召唤卡</option>
					</select>
				</td>
			</tr>
			<tr class="row">
				<td width="15%">物品数量:</td>
				<td>
					<input type="text" id="goods_num" name="goods_num"  value=1 />数量，默认一个。强化的物品只能发一个
				</td>
			</tr>
			<tr class="row">
				<td width="15%">强化等级:</td>
				<td><input type="text" id="strenLevel" name="strenLevel"  value="0"/></td>
			</tr>
			<tr class="row">
				<td width="15%">金币:</td>
				<td><input type="text" id="coin_count" name="coin_count" value="0"/></td>
			</tr>
			<tr class="row">
				<td width="15%">元宝:</td>
				<td><input type="text" id="gold_count" name="gold_count"  value="0"/></td>
			</tr>
			<tr class="row">
				<td width="15%">绑定类型:</td>
				<td>
					<input type="radio" id="bind_type" name="bind_type" value="0" />不绑定
					<input type="radio" id="bind_type" name="bind_type" value="1" checked/>绑定
					<input type="radio" id="bind_type" name="bind_type" value="2"/>不知道是啥
				</td>
			</tr>
			<tr class="row">
				<td width="15%">是否可交易:</td>
				<td>
					<input type="radio" id="istrade" name="istrade" value="0"/>可以
					<input type="radio" id="istrade" name="istrade" value="1" checked/>不可以
				</td>
			</tr>
			<tr>
				<td height="3" colspan="2" class="bottomtd"><button id="send" onclick="sendMail()">发送邮件</button></td>
			</tr>
		</table>
	</div>
</div>
<!-- 主页面结束 -->
{// 加载尾部公共文件 }
<script type="text/javascript">

	$("#commenItem").change(function(){
		$("#goods_id").val($("#commenItem").val());
	});


	var cdn_path	=	"http://1251001850.cdn.myqcloud.com/1251001850/xbmc/icon/goodsPic/";
	//物品变化了
	function goodsChang()
	{
		$("#goodsImg").attr("src",cdn_path+$("#goods_id").val()+".png");
	}
	
	//发送邮件吧
	function sendMail()
	{
		if(userid==""||userid==null)
		{
			alert("先查询一下用户。");
			return false;
		}
		var title	=	$("#title").val();
		var content	=	$("#content").val();
		var goods_id	=	$("#goods_id").val();
		var goods_num	=	$("#goods_num").val();
		var strenLevel	=	$("#strenLevel").val();
		var coin	=	$("#coin_count").val();
		var gold	=	$("#gold_count").val();
		var bind_type	=	$("#bind_type").val();
		var istrade	=	$("#istrade").val();
		
		if(strenLevel>1&&goods_num>1)
		{
			alert("强化的物品只能发一个。");
			return false;
		}
		
		var urldata	=	{};
		urldata.uid	=	userid;
		urldata.goods_id	=	goods_id;
		//urldata.goods_num	=	goods_num;
		urldata.strenLevel	=	strenLevel;
		urldata.title	=	title;
		urldata.content	=	content;
		urldata.coin	=	coin;
		urldata.gold	=	gold;
		urldata.bind_type	=	bind_type;
		urldata.istrade	=	istrade;
		$.get("{:U('Game/sendmail')}",urldata,function(data){
			alert("发送成功，请联系玩家查收。"+data);
		});
	}
	
	
	function resetAll()
	{
		
	}
	
	function enableAll()
	{
	}
	var userid	=	"";
	/**
	* 检查玩家
	**/
	function checkUser()
	{
		username	=	$("#uname").val();
		var urldata	=	{};
		urldata.type	=	"user";
		urldata.name	=	username;
		//var econtent = escape(username);
		$.get("{:U('Game/query')}",urldata, function(data) {
			if(data=="")
			{
				//玩家不存在
				resetAll();
			}
			else
			{
				enableAll();
				userid	=	data;
				$("#userinfo").html(userid);
			}
		});
	}
	
</script>